Skip to content

Hw2 - #112

Open
GlebOgl wants to merge 2 commits into
L1mple:mainfrom
GlebOgl:hw2
Open

Hw2#112
GlebOgl wants to merge 2 commits into
L1mple:mainfrom
GlebOgl:hw2

Conversation

@GlebOgl

@GlebOgl GlebOgl commented Oct 4, 2026

Copy link
Copy Markdown

No description provided.

@DevDenus DevDenus left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Хорошая работа, молодец!

Comment thread hw2/hw/shop_api/main.py
@app.put("/item/{item_id}", response_model=ItemResponse)
async def put_item(item_id: int, body: ItemPut) -> ItemResponse:
item = _items.get(item_id)
if item is None or item.deleted:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше тут разделить, для несуществующих отдавать 404, а для deleted - 304

Comment thread hw2/hw/shop_api/main.py
@app.patch("/item/{item_id}", response_model=ItemResponse)
async def patch_item(item_id: int, body: ItemPatch) -> ItemResponse:
item = _items.get(item_id)
if item is None or item.deleted:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше тут разделить, для несуществующих отдавать 404, а для deleted - 304

Comment thread hw2/hw/shop_api/main.py
carts = [c for c in carts if sum(i.quantity for i in c.items) >= min_quantity]
if max_quantity is not None:
carts = [c for c in carts if sum(i.quantity for i in c.items) <= max_quantity]
return carts[offset : offset + limit]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше limit и offset внутри цикла обрабатывать, чтобы лишнего не набирать

Comment thread hw2/hw/shop_api/main.py
@app.delete("/item/{item_id}")
async def delete_item(item_id: int) -> dict:
item = _items.get(item_id)
if item is not None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

для ненайденных по хорошему 404 отдавать

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants